import Opt from '@/components/dt/info/Opt.js'
import houseOpt from '@/biz/option/house.js'
import organizationOpt from '@/biz/option/organization.js'

//bill
//billApproval
//billApprovalManager
//caseBillApproval


class SearchOpt extends Opt {
  
  constructor(name) {
    super()
    this.name = name
    this.build()
  }
  
  build() {
    this.createAll()
    if (this.name != 'bill' && this.name != 'caseBillApproval') {
      this.opts.push(...this.approval)
    }
    this.opts.push(...this.all)
  }

  createAll() {
    
    this.approval = [
      organizationOpt.create(),
      houseOpt.create({
        to: (info) => {
          return {
            housesId: info.housesId
          }
        }
      })
    ]
    this.all = [{
        title: '奖金单类型',
        key: 'bonusType',
        placeholder: '全部',
        select: {
          key: 'bonusType'
        },
        data: {
          to: (val) => {
            return {
              bonusType: val ? this.name == 'bill' ? val.value : val.label : null
            }
          }
        }
      },
      {
        title: '奖金单月份',
        placeholder: '全部',
        key: 'bonusMonth',
        date: {
          type: 'month'
        },
      },
      {
        title: '状态',
        placeholder: '全部',
        visible: this.name != 'billApproval' && this.name != 'caseBillApproval',
        key: this.name == 'bill' ? 'status' : 'state',
        select: {
          key: this.name == 'bill' ? 'bonusAwardStatus' : 'processAuditStatus'
        }
      }
    ]
  }
}

export default SearchOpt
